package com.example.lottery.common.config;

import com.example.lottery.common.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;


@Configuration
public class AppConfigurer implements WebMvcConfigurer {
@Autowired
private LoginInterceptor loginInterceptor;

    /**
     * 第一个/前面就是URL的地址 127.0.0.1、。。。。
     */
    private static final List<String> excludes=Arrays.asList(
        "/**/*.html",
        "/css/**",
        "/js/**",
        "/pic/**",
        "/*.jpg",
        "/*.png",
        "/*.webp",
        "/favicon.ico",
        "/user/**/login",
        "/user/register",
        "/user/verification-code/send",
        "/user/exit",
            "/winning-records/show"
);
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(excludes);
    }
}
